<template>
  <a-dropdown>
    <span >
      <a-icon type="global" style="font-size: 16px"/>
      <span>{{ $t('language_switch') }}</span>
    </span>
    <a-menu slot="overlay" @click="onClick">
      <a-menu-item key="zh_CN" :disabled="disabledItem('zh_CN')">简体中文</a-menu-item>
      <a-menu-item key="en_US" :disabled="disabledItem('en_US')">English</a-menu-item>
    </a-menu>
  </a-dropdown>
</template>
<script>

export default {
  data () {
    return {
    }
  },
  methods: {
    onClick({ key }) {
      localStorage.locale = `${key}` // 把locale信息保存到localStorage
      this.$i18n.locale = localStorage.locale
    },
    disabledItem(key) {
      return key == this.$i18n.locale // 置灰当前选中的语言
    }
  },
};
</script>
<style scoped>

</style>